﻿// 文件名：函数与array对象
// 创建时间：2021/6/21/星期一 19:54:16

#include <iostream>
using namespace std;
#include <array>
#include <string>
//使用array存储一年四季的开支
const int Seasons = 4;
const array<string, Seasons> Snames = { "Spring","Summer","Fall","Winter" };
void fill(array<double, Seasons> *pa);
void show(array<double, Seasons> da);
int main()
{
	array<double, Seasons> expenses;
	fill(&expenses);
	show(expenses);
	system("pause");
	return 0;
}

void fill(array<double, Seasons>* pa)
{
	for (int i = 0; i < Seasons; i++)
	{
		cout << "Enter " << Snames[i] << " expenses: ";
		cin >> (*pa)[i];
	}
}
void show(array<double, Seasons> da)
{
	double total = 0.0;
	cout << "\nExpenses\n";
	for (int i = 0; i < Seasons; i++)
	{
		cout << Snames[i] << ":$"<<da[i] << endl;
		total += da[i];
	}
	cout << "Total Expenses: $" << total << endl;
}